home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / p063b9s.zip / UNIT / OPROUTIL.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-28  |  18KB  |  660 lines

  1. UNIT OproUtil;
  2. {╔══════════════════════════════════════════════════════════════════════════╗}
  3. {║ Misc. routines for OPro                       Last changed: 28.04.96  SA ║}
  4. {║                                                                          ║}
  5. {║                         (C) Copyright 1989-96 by                         ║}
  6. {║       Dan Wulff, Jens Sandalgaard, Steen Christensen & S¢ren Ager        ║}
  7. {║                                                                          ║}
  8. {║ This source may not be given to anybody, without the written permission  ║}
  9. {║ from The Portal Team.                                                    ║}
  10. {╚══════════════════════════════════════════════════════════════════════════╝}
  11. {$I POPDEFS.INC}
  12.  
  13. INTERFACE
  14.  
  15. USES Use32, Dos, OpCrt, OpWindow, OpMenu, OpField, OpEntry, OpRoot,
  16.      PoPTypes;
  17.  
  18. CONST
  19.   ptBitYesNoConversion = 2000;
  20.   otBitYesNoEField     = 1101;
  21.   veBitYesNoEField     = 0;
  22.  
  23. TYPE
  24.   PBufTextFile = ^TBufTextFile;
  25.   TBufTextFile = OBJECT(BufIdStream)
  26.     ReadWrite : Boolean;
  27.  
  28.     CONSTRUCTOR Init(CONST FileName: PathStr; Mode, Size : Word);
  29.     CONSTRUCTOR InitCreate(FileName: PathStr; Mode, Size: Word);
  30.     PROCEDURE ReadLn(VAR s: String);
  31.     PROCEDURE WriteLn(s: String);
  32.     PROCEDURE WriteNoLn(s: String);
  33.     PROCEDURE ReadLenStr(VAR s: String; Len: Byte);
  34.     FUNCTION  EoF: Boolean;
  35.   END;
  36.  
  37.   PPoPEntryScreen = ^TPoPEntryScreen;
  38.   TPoPEntryScreen = OBJECT(ScrollingEntryScreen)
  39.     CONSTRUCTOR Init(x1, y1, x2, y2, Col: Byte; CONST s: s78);
  40.     DESTRUCTOR  Done; VIRTUAL;
  41.     PROCEDURE   Process; VIRTUAL;
  42.     PROCEDURE   AddBitYesNoField(Prompt: STRING;  pRow, pCol : Word;
  43.                                  Picture: STRING; fRow, fCol : Word;
  44.                                  HelpIndex: Word; BitNr: Byte; VAR EditBitYesNo: SmallWord);
  45.   END;
  46.  
  47.   PBitYesNoField = ^TBitYesNoField;
  48.   TBitYesNoField = OBJECT(EntryField)
  49.     BitNr : Byte;
  50.  
  51.     constructor Init(ID : Word;               var Prompt : string;
  52.                      pRow, pCol : Word;       var Picture : string;
  53.                      fRow, fCol : Word;       HlpNdx : Word;
  54.                      ABitNr: Byte; var EditBitYesNo : SmallWord; PadChar : Char;
  55.                      Options, IFlags : LongInt; var Colors : ColorSet);
  56.     procedure efIncrement; VIRTUAL;
  57.  
  58.     constructor Load(var S : IdStream);
  59.     procedure  Store(var S : IdStream); VIRTUAL;
  60.   END;
  61.  
  62.   PPoPMenu = ^TPoPMenu;
  63.   TPoPMenu = OBJECT(Menu)
  64.     CONSTRUCTOR Init(x1, y1, x2, y2, Col: Byte; CONST s: s78);
  65.     DESTRUCTOR  Done; VIRTUAL;
  66.     PROCEDURE   ProcessMenu(VAR Choice, LastCmd: Word);
  67.   END;
  68.  
  69. { Stream registration }
  70. PROCEDURE TPoPEntryScreenStream(SPtr: IdStreamPtr);
  71. PROCEDURE TPoPMenuStream(SPtr: IdStreamPtr);
  72. PROCEDURE TBitYesNoFieldStream(SPtr: IdStreamPtr);
  73.  
  74. PROCEDURE CenterWindow(VAR x1, x2: Byte);
  75.  
  76. FUNCTION  MyWin(VAR w : WindowPtr; x1, y1, x2, y2, l : Byte; CONST s: String; Shadow: Boolean): Boolean;
  77. PROCEDURE KillWindow(VAR w : WindowPtr);
  78.  
  79. PROCEDURE LoadMainMenu;
  80. PROCEDURE MainMenuToggle;
  81.  
  82. FUNCTION GetDiskString(Drive: Char): S25;
  83.  
  84. IMPLEMENTATION
  85.  
  86. USES {$IFDEF OS2} Os2Base, VpRoot, {$ELSE} OpMacro, {$ENDIF} OpDos,
  87.      OpInline, OpFrame, OpSelect, OpCmd, OpKey, OpAbsFld, OpFEdit, OpConst,
  88.      Globals, Resource, PoPHelp;
  89.  
  90.  
  91. {=== TBufTextFile ===}
  92.  
  93.   CONSTRUCTOR TBufTextFile.Init(CONST FileName: PathStr; Mode, Size: Word);
  94.   BEGIN
  95.     Size:=(Size DIV 512)*512;
  96.     IF Size=0 THEN Size:=512;
  97.     IF NOT INHERITED Init(FileName, Mode, Size) THEN Fail;
  98.     IF GetStatus<>0 THEN
  99.     BEGIN
  100.       INHERITED Done;
  101.       Fail;
  102.     END;
  103.     ReadWrite:=((Mode AND SOpen)=SOpen) OR ((Mode AND SCreate)=SCreate);
  104.   END;
  105.  
  106.   CONSTRUCTOR TBufTextFile.InitCreate(FileName: PathStr; Mode, Size: Word);
  107.   BEGIN
  108.     IF NOT ExistFile(FileName) THEN Mode:=SCreate;
  109.     IF NOT Init(FileName, Mode, Size) THEN Fail;
  110.     SetPos(0, PosEnd);
  111.   END;
  112.  
  113.  
  114.   Procedure TBufTextFile.ReadLn(var S: String);
  115.   var
  116.     SPos : Byte;
  117.     Ch   : Char;
  118. {$IFNDEF OS2}
  119.     Regs : Registers;
  120. {$ENDIF}
  121.   begin
  122.     S[0]:=#0; SPos:=0; Ch:=#0;
  123. {   if idStatus<>0 then Exit;}
  124.     if ReadWrite and not FlushBuffer(1) then Exit;   { = FlushModeWrite }
  125.     repeat
  126.       if BufPtr>=BufEnd then
  127. {$IFDEF OS2}
  128.       asm
  129.         push   ebx
  130.         mov    eax,self
  131.         mov    ebx,[eax].DosIdStream.Handle
  132.         mov    ecx,[eax].DosIdStream.BufSize
  133.         mov    edx,[eax].DosIdStream.Buffer
  134.         mov    ah,3fh         { Read }
  135.         Call   Os2DosFn
  136.         jnc    @@1              { success }
  137.  
  138.         add     eax,epNonFatal  { error }
  139.         push    eax
  140.         mov     eax,Self
  141.         push    eax
  142.         Call    Error
  143.         jmp     @@2
  144.       @@1:
  145.  
  146.         mov     ebx,self
  147.         xor     ecx,ecx
  148.         mov     [ebx].DosIdStream.bufptr,ecx
  149.         mov     [ebx].DosIdStream.bufend,eax
  150.  
  151.         or      eax,eax         { check if bytes read = 0 }
  152.         jne     @@2
  153.         mov     eax,epNonFatal  { nope - disk full }
  154.         add     eax,ecDiskRead
  155.         push    eax
  156.         mov     eax,Self
  157.         push    eax
  158.         Call    Error
  159.       @@2:
  160.         pop     ebx
  161.       end;
  162. {$ELSE}
  163.       begin
  164.         with Regs do
  165.         begin
  166.           AH := $3F;
  167.           BX := Handle;
  168.           CX := BufSize;
  169.           DX := OS(Buffer).O;
  170.           DS := OS(Buffer).S;
  171.           MsDos(Regs);
  172.           BufPtr:=0;
  173.           IF Odd(Flags) THEN BufEnd:=0 ELSE BufEnd:=AX;
  174.         end;
  175.       end;
  176. {$ENDIF}
  177.       WHILE (BufPtr<BufEnd) AND (Ch<>#10) DO
  178.       BEGIN
  179.         Ch:=Char(Buffer^[BufPtr]);
  180.         IF (not (ch in [#13, #10])) AND (SPos<=255) THEN
  181.         BEGIN
  182.           Inc(SPos);
  183.           s[SPos]:=ch;
  184.         END;
  185.         Inc(BufPtr);
  186.       END;
  187.     UNTIL (Ch=#10) or (BufEnd=0);
  188.     S[0]:=Char(SPos);
  189.   END;
  190.  
  191.   PROCEDURE TBufTextFile.WriteLn(s: String);
  192.   BEGIN
  193.     Write(s[1], Length(s));
  194.     s:=#13#10;
  195.     Write(s[1], Length(s));
  196.   END;
  197.  
  198.   PROCEDURE TBufTextFile.WriteNoLn(s: String);
  199.   BEGIN
  200.     Write(s[1], Length(s));
  201.   END;
  202.  
  203.   PROCEDURE TBufTextFile.ReadLenStr(VAR s: String; Len: Byte);
  204.   BEGIN
  205.     Read(s[1], Len);
  206.     s[0]:=Char(Len);
  207.   END;
  208.  
  209. {$IFDEF OS2}
  210.   FUNCTION TBufTextFile.EoF: Boolean;
  211.   VAR
  212.     OldPos, NewPos : LongInt;
  213.   BEGIN
  214.     DosSetFilePtr(Handle, 0, FILE_CURRENT, OldPos);
  215.     DosSetFilePtr(Handle, 0, FILE_END, NewPos);
  216.     DosSetFilePtr(Handle, OldPos, FILE_BEGIN, OldPos);
  217.     EoF:=(OldPos=NewPos) AND (BufPtr>=BufEnd);
  218.   END;
  219.  
  220. {$ELSE}
  221.  
  222.   FUNCTION TBufTextFile.EoF: Boolean;
  223.   VAR
  224.     Regs : Registers;
  225.     OldDX, OldAX,
  226.     MaxDX, MaxAX : Word;
  227.   BEGIN
  228.     IF (BufPtr>0) AND (Succ(BufPtr)<BufEnd) THEN
  229.       EoF:=False
  230.     ELSE
  231.     begin
  232. (*
  233.       ASM
  234.         mov ax,$4201
  235.         mov bx,Handle
  236.         mov cx,0
  237.         mov dx,0
  238.         int $21
  239.         mov OldDx,dx
  240.         mov OldAx,ax
  241.  
  242.         mov ax,$4202
  243.         mov bx,Handle
  244.         mov cx,0
  245.         mov dx,0
  246.         int $21
  247.         mov MaxDx,dx
  248.         mov MaxAx,ax
  249.  
  250.         mov ax,$4200
  251.         mov bx,Handle
  252.         mov cx,OldDx
  253.         mov dx,OldAX
  254.         int $21
  255.       END;
  256. *)
  257.       WITH Regs DO
  258.       BEGIN
  259.         ax:=$4201;
  260.         bx:=Handle;
  261.         cx:=0;
  262.         dx:=0;
  263.         MsDos(Regs);
  264.         OldDX:=DX;
  265.         OldAX:=AX;
  266.  
  267.         ax:=$4202;
  268.         bx:=Handle;
  269.         cx:=0;
  270.         dx:=0;
  271.         MsDos(Regs);
  272.         MaxDX:=DX;
  273.         MaxAX:=AX;
  274.  
  275.         ax:=$4200;
  276.         bx:=Handle;
  277.         cx:=OldDX;
  278.         dx:=OldAX;
  279.         MsDos(Regs);
  280.       END;
  281.       EoF:=(OldDX=MaxDX) AND (OldAX=MaxAX) AND (BufPtr>=BufEnd);
  282.     END;
  283.   END;
  284. {$ENDIF}
  285.  
  286.  
  287. {=== TPoPEntryScreen ===}
  288.  
  289.   CONSTRUCTOR TPoPEntryScreen.Init(x1, y1, x2, y2, Col: Byte; CONST s: s78);
  290.   BEGIN
  291.     CenterWindow(x1, x2);
  292.     IF NOT INHERITED InitCustom(x1,y1,x2,y2,Cfg.Color[col],wBordered+wClear) THEN Fail;
  293.     WFrame.AddHeader(' '+s+' ',heTC);
  294.     IF (x2<ScreenWidth-2) AND (y2<ScreenHeight-2) THEN WFrame.AddShadow(shBR, shSeeThru);
  295.     IF cfg.Screen.ExplodingWin THEN EnableExplosions(10);
  296.     esFieldOptionsOn(efClearFirstChar);
  297.     SetWrapMode(ExitAtBot);
  298.     EntryCommands.AddCommand(ccPrevRec,1,OpKey.PgUp,0);
  299.     EntryCommands.AddCommand(ccNextRec,1,OpKey.PgDn,0);
  300.     EntryCommands.SetHelpProc(HelpRoutine);
  301.     Topic:=0;
  302.   END;
  303.  
  304.   DESTRUCTOR TPoPEntryScreen.Done;
  305.   BEGIN
  306.     EraseHidden;
  307.     INHERITED Done;
  308.   END;
  309.  
  310.   PROCEDURE TPoPEntryScreen.Process;
  311.   BEGIN
  312.     ResetScreen;
  313.     INHERITED Process;
  314.   END;
  315.  
  316.   PROCEDURE TPoPEntryScreen.AddBitYesNoField(Prompt: STRING;  pRow, pCol : Word;
  317.                                              Picture: STRING; fRow, fCol : Word;
  318.                                              HelpIndex: Word; BitNr: Byte; VAR EditBitYesNo: SmallWord);
  319.   VAR
  320.     fWidth : Byte;
  321.   BEGIN
  322.     {check parameters before adding the field}
  323.     fWidth := Length(Picture);
  324.     if esParamsOK(Prompt, pRow, pCol, Picture, fRow, fCol, fWidth) then
  325.       {allocate field and append it to the linked list}
  326.       esAppendField(
  327.         New(PBitYesNoField,
  328.             Init(asCount, Prompt, pRow, pCol, Picture, fRow, fCol, HelpIndex,
  329.                  BitNr, EditBitYesNo, esPadChar, asFieldOptions, esFieldFlags, asColors)));
  330.   END;
  331.  
  332.  
  333.  
  334.   procedure BitYesNoConversion(EFP: EntryFieldPtr; PostEdit:  Boolean); far;
  335.     {-Conversion routine for yes/no's}
  336.   var
  337.     Ch : Char;
  338.     S : string[10];
  339.   begin
  340.     with PBitYesNoField(EFP)^ do
  341.       if PostEdit then
  342.       begin
  343.         StripPicture(efEditSt^, S);
  344.         Ch := S[1];
  345.         IF Upcase(Ch) = YesChar THEN
  346.           Word(efVarPtr^):=Word(efVarPtr^) OR (1 SHL BitNr)
  347.         ELSE
  348.           Word(efVarPtr^):=Word(efVarPtr^) AND NOT (1 SHL BitNr);
  349.       end else
  350.       begin
  351.         if Word(efVarPtr^) AND (1 SHL BitNr) <> 0 then
  352.           efEditSt^ := YesChar
  353.         else
  354.           efEditSt^ := NoChar;
  355.         if Length(efEditSt^) < Length(efPicture^) then
  356.           MergePicture(efEditSt^, efEditSt^);
  357.       end;
  358.   end;
  359.  
  360.  
  361.  
  362.  
  363.  
  364.   constructor TBitYesNoField.Init(ID : Word;               var Prompt : string;
  365.                                   pRow, pCol : Word;       var Picture : string;
  366.                                   fRow, fCol : Word;       HlpNdx : Word;
  367.                                   ABitNr: Byte; var EditBitYesNo : SmallWord; PadChar : Char;
  368.                                   Options, IFlags : LongInt; var Colors : ColorSet);
  369.     {-Initialize an entry field of type yes-no}
  370.   var
  371.     fWidth : Byte;
  372.   begin
  373.     if Length(Picture) = 0 then
  374.     begin
  375.       Picture := YesNoOnly;
  376.       fWidth := 1;
  377.     end else
  378.       fWidth := Length(Picture);
  379.  
  380.     if not INHERITED Init(
  381.       ID, Prompt, pRow, pCol, Picture, fRow, fCol, fWidth, 1, HlpNdx,
  382.       BlankRange, BlankRange, SizeOf(Boolean), 0, NullValidation, BitYesNoConversion,
  383.       DrawString, CharEditor, EditBitYesNo, PadChar, Options or efClickExit,
  384.       IFlags or ifBoolean, Colors) then
  385.         Fail;
  386.     BitNr:=ABitNr;
  387.   end;
  388.  
  389.   procedure TBitYesNoField.efIncrement;
  390.     {-Increment the value of the field}
  391.   begin
  392.     Word(efVarPtr^) := Word(efVarPtr^) XOR (1 SHL BitNr);
  393.   end;
  394.  
  395.   constructor TBitYesNoField.Load(var S : IdStream);
  396.   BEGIN
  397.     INHERITED Load(S);
  398.     S.Read(BitNr, SizeOf(BitNr));
  399.   END;
  400.  
  401.   procedure TBitYesNoField.Store(var S : IdStream);
  402.   BEGIN
  403.     INHERITED Store(S);
  404.     S.Write(BitNr, SizeOf(BitNr));
  405.   END;
  406.  
  407. {***}
  408.  
  409.  
  410.   procedure TBitYesNoFieldStream(SPtr : IdStreamPtr);
  411.     {-Register all types}
  412.   begin
  413.     EntryFieldStream(SPtr);
  414.     with SPtr^ do begin
  415.       RegisterType(otBitYesNoEField, veBitYesNoEField, TypeOf(TBitYesNoField),
  416.                    @TBitYesNoField.Store, @TBitYesNoField.Load);
  417.       RegisterPointer(ptBitYesNoConversion, @BitYesNoConversion);
  418.       RegisterPointer(ptDrawString, @DrawString);
  419.       RegisterPointer(ptCharEditor, @CharEditor);
  420.     end;
  421.   end;
  422.  
  423.  
  424. {=== TPoPMenu ===}
  425.  
  426.   CONSTRUCTOR TPoPMenu.Init(x1, y1, x2, y2, Col: Byte; CONST s: s78);
  427.   BEGIN
  428.     CenterWindow(x1, x2);
  429.     IF NOT INHERITED InitCustom(x1,y1,x2,y2,Cfg.Color[col],wBordered+wCoversOnDemand,Vertical) THEN Fail;
  430.     WFrame.AddHeader(' '+s+' ',heTC);
  431.     IF (x2<ScreenWidth-2) AND (y2<ScreenHeight-2) THEN AddShadow(shBR, shSeeThru);
  432.     IF cfg.Screen.ExplodingWin THEN EnableExplosions(10);
  433.     Topic:=0 ;
  434.   END;
  435.  
  436.   DESTRUCTOR TPoPMenu.Done;
  437.   BEGIN
  438.     EraseHidden;
  439.     INHERITED Done;
  440.   END;
  441.  
  442.   PROCEDURE TPoPMenu.ProcessMenu(VAR Choice, LastCmd: Word);
  443.   BEGIN
  444.     Draw;
  445.     Process;
  446.     Choice:=MenuChoice;
  447.     LastCmd:=GetLastCommand;
  448.     Done;
  449.    END;
  450.  
  451.  
  452. {=== Stream Registration ===}
  453.  
  454.   PROCEDURE TPoPEntryScreenStream(SPtr: IdStreamPtr);
  455.   BEGIN
  456.     ScrollingEntryScreenStream(SPtr);
  457.     SPtr^.RegisterType(otTPopEntryScreen, veTPoPEntryScreen,
  458.                        TypeOf(TPoPEntryScreen),
  459.                        @TPoPEntryScreen.Store, @TPoPEntryScreen.Load);
  460.   END;
  461.  
  462.   PROCEDURE TPoPMenuStream(SPtr: IdStreamPtr);
  463.   BEGIN
  464.     MenuStream(SPtr);
  465.     SPtr^.RegisterType(otTPopMenu, veTPoPMenu,
  466.                        TypeOf(TPoPMenu),
  467.                        @TPoPMenu.Store, @TPoPMenu.Load);
  468.   END;
  469.  
  470.  
  471.   PROCEDURE CenterWindow(VAR x1, x2: Byte);
  472.   BEGIN
  473.     IF ScreenWidth>80 THEN
  474.     BEGIN
  475.       Inc(x1, (ScreenWidth-80) DIV 2);
  476.       Inc(x2, (ScreenWidth-80) DIV 2);
  477.     END;
  478.   END;
  479.  
  480.   FUNCTION MyWin(VAR w : WindowPtr; x1, y1, x2, y2, l : Byte; CONST s: String; Shadow: Boolean): Boolean;
  481.   VAR
  482.     Head : String;
  483.     cs   : ColorSet;
  484.     b    : LONGINT;
  485.   BEGIN
  486.     IF l=0 THEN cs:=DefaultColorSet ELSE cs:=Cfg.Color[l];
  487.     b:=wClear+wSaveContents;
  488.     CenterWindow(x1, x2);
  489.     IF s='' THEN
  490.     BEGIN
  491.       Head:='';
  492.     END ELSE
  493.     BEGIN
  494.       INC(x1);INC(y1);DEC(x2);DEC(y2);
  495.       Head:=' '+s+' ';
  496.       b:=b+wBordered;
  497.     END;
  498.     New(w, InitCustom(x1,y1,x2,y2,cs,b));
  499.     IF w<>NIL THEN
  500.     BEGIN
  501.       w^.SetCursor(cuHidden);
  502.       IF head<>'' THEN w^.WFrame.AddHeader(Head,heTC);
  503.       IF Cfg.Screen.ExplodingWin THEN w^.EnableExplosions(10);
  504.       IF Shadow THEN w^.wFrame.AddShadow(shBR,shSeeThru);
  505.       w^.Draw;
  506.       MyWin:=True;
  507.     END ELSE
  508.       MyWin:=False;
  509.   END;
  510.  
  511.   PROCEDURE KillWindow(VAR w : WindowPtr);
  512.   BEGIN
  513.     w^.EraseHidden;
  514.     Dispose(w, Done);
  515.   END;
  516.  
  517.  
  518.   PROCEDURE InitM(VAR M:Menu; x1,y1,x2,y2,col:BYTE; CONST s: STRING);
  519.   BEGIN
  520.     WITH m DO
  521.     BEGIN
  522.       CenterWindow(x1, x2);
  523.       InitCustom(x1,y1,x2,y2,Cfg.Color[col],wBordered,Vertical);
  524.       WFrame.AddHeader(' '+s+' ',heTC);
  525.       IF cfg.Screen.ExplodingWin THEN EnableExplosions(6);
  526.     END;
  527.     Topic:=0 ;
  528.   END;
  529.  
  530.   PROCEDURE _KillMenu(VAR m:Menu);
  531.   BEGIN
  532.     m.EraseHidden;
  533.     m.Done;
  534.   END;
  535.  
  536.  
  537.   PROCEDURE MainCustomStringProc(var Name : String; Key : LongInt;
  538.                                  Selected, Highlighted : Boolean;
  539.                                  WPtr : RawWindowPtr); far;
  540.   VAR
  541.     s : S5;
  542.   BEGIN
  543. {$IFNDEF OS2}
  544.     IF Key=93 THEN
  545.     BEGIN
  546.       IF MacrosAreOn THEN s:='Yes' ELSE s:=' No';
  547.       Move(s[1], Name[Length(Name)-2], Length(s));
  548.     END;
  549. {$ENDIF}
  550.   END;
  551.  
  552.   PROCEDURE LoadMainMenu;
  553.   BEGIN
  554.     IF MainMenu=NIL THEN
  555.     BEGIN
  556.       New(MainMenu);
  557.       GetMenu(MnuMain, 2, MainMenu^);
  558.       MainMenu^.SetCustomStringProc(MainCustomStringProc);
  559.       MainMenu^.DefaultItem(100);
  560.     END;
  561.     MainMenuToggle;
  562.   END;
  563.  
  564.   PROCEDURE MainMenuToggle;
  565.   BEGIN
  566.     WITH MainMenu^ DO
  567.     BEGIN
  568.       IF CmdLineFlags AND clNoModem<>0 THEN
  569.       BEGIN
  570.         ProtectItem(AltP);
  571.         ProtectItem(AltD);
  572.         ProtectItem(AltC);
  573.         ProtectItem(210);
  574.         ProtectItem(211);
  575.         ProtectItem(212);
  576.       END ELSE
  577.       BEGIN
  578.         UnProtectItem(AltP);
  579.         UnProtectItem(AltD);
  580.         UnProtectItem(AltC);
  581.         UnProtectItem(210);
  582.         UnProtectItem(211);
  583.         UnProtectItem(212);
  584.         IF Cfg.Modem.Answer='' THEN ProtectItem(211) ELSE UnProtectItem(211);
  585.       END;
  586.  
  587.       IF OutList^.Size=0 THEN
  588.       BEGIN
  589.         ProtectItem(Plus);
  590.         ProtectItem(Minus);
  591.         ProtectItem(AltW);
  592.         ProtectItem(AltI);
  593.       END ELSE
  594.       BEGIN
  595.         UnProtectItem(Plus);
  596.         UnProtectItem(Minus);
  597.         UnProtectItem(AltW);
  598.         UnProtectItem(AltI);
  599.       END;
  600.  
  601.       IF Cfg.Screen.BlankTime=0 THEN ProtectItem(AltB) ELSE UnProtectItem(AltB);
  602.       IF Cfg.Editor='' THEN ProtectItem(AltE) ELSE UnProtectItem(AltE);
  603.       IF Cfg.BBS.BBSType=btNone THEN
  604.       BEGIN
  605.         ProtectItem(AltA);
  606.         ProtectItem(AltQ);
  607.         ProtectItem(AltU);
  608.       END ELSE
  609.       BEGIN
  610.         UnProtectItem(AltA);
  611.         UnProtectItem(AltQ);
  612.         UnProtectItem(AltU);
  613.       END;
  614. {$IFNDEF OS2}
  615.       IF MacroCount=0 THEN
  616.       BEGIN
  617.         ProtectItem(91);
  618.         ProtectItem(92);
  619.         ProtectItem(94);
  620.         ProtectItem(97);
  621.       END ELSE
  622.       BEGIN
  623.         UnProtectItem(91);
  624.         UnProtectItem(92);
  625.         UnProtectItem(94);
  626.         UnProtectItem(97);
  627.       END;
  628. {$ENDIF}
  629. {     ProtectItem(214);
  630.       ProtectItem(215);}
  631.     END;
  632.   END;
  633.  
  634.   FUNCTION GetDiskString(Drive: Char): S25;
  635.   VAR
  636.     dc : DiskClass;
  637.     sd : Char;
  638.   BEGIN
  639.     GetDiskString:='';
  640.     dc:=GetDiskClass(Drive, sd);
  641.     CASE dc OF
  642.       Floppy360    : GetDiskString:='360KB floppy';
  643.       Floppy720    : GetDiskString:='720KB floppy';
  644.       Floppy12     : GetDiskString:='1.2MB floppy';
  645.       Floppy144    : GetDiskString:='1.44MB floppy';
  646.       OtherFloppy  : GetDiskString:='Unknown floppy';
  647.       Bernoulli    : GetDiskString:='Bernoulli drive';
  648.       HardDisk     : GetDiskString:='Hard disk';
  649.       RamDisk      : GetDiskString:='Ram drive';
  650.       SubstDrive   : GetDiskString:='Substitute of drive '+sd;
  651.       UnknownDisk  : GetDiskString:='Unknown media';
  652.       InvalidDrive : GetDiskString:='Invalid drive';
  653.       NovellDrive  : GetDiskString:='Novell<tm> drive';
  654.       CDRomDisk    : GetDiskString:='CD ROM drive';
  655.     END;
  656.   END;
  657.  
  658. END.
  659.  
  660.